function dynamic_load_content(container, content_url) {
    container = $(container);
    console.log("Loading content " + content_url + " into " + container.id);
    new Ajax.Updater(container, content_url, {
        method: 'get',
        onSuccess: function() {
            console.log('load success');
        },
        onFailure: function() {
            console.log('load failure');
        }
    });
//    var prefs = new gadgets.Prefs();
//    var scroll = prefs.getString('scroll');
//    var height = 800;
//    var width = 600;
//
//    if (gadgets.window) {
//        var viewport = gadgets.window.getViewportDimensions();
//        if (viewport.width) {
//            var width = viewport.width;
//        }
//        if (viewport.height) {
//            var height = viewport.height;
//        }
//    }
//    var iframe = document.createElement('iframe');
//    iframe.setAttribute('width', width + 'px');
//    iframe.setAttribute('height', height + 'px');
//    iframe.setAttribute('frameborder', 'no');
//    if (scroll) {
//        iframe.setAttribute('scrolling', scroll);
//    }
//    iframe.setAttribute('src', content_url);
//
//    // set the slideshow to the placeholder div
//    parent.innerHTML = '';
//    parent.insert(iframe);
    console.log("dynamic_load_content complete");
}
function dynamic_load_behavior(parent, behavior_url) {
    parent = $(parent);
    console.log("Loading behavior " + behavior_url + " into " + parent.id);
    var behavior_script = document.createElement('script');
    behavior_script.setAttribute("src", behavior_url);
    behavior_script.setAttribute("type", "text/javascript");
    parent.insert({after:behavior_script});
    console.log("load behavior complete");
}
function dynamic_load_css(parent, css_url) {
    parent = $(parent);
    console.log("Loading style " + css_url + " into " + parent.id);
    var cssfile = document.createElement("link");
    cssfile.setAttribute("rel", "stylesheet");
    cssfile.setAttribute("type", "text/css");
    cssfile.setAttribute("href", css_url);
    parent.insert(cssfile);
    console.log("load style complete");
}
var timestamp = new Date().getTime();
dynamic_load_css($('gadget_content'), "http://troper-mp.local/~localadmin/rally_scheduler_style.css?timestamp=" + timestamp);
dynamic_load_content($('gadget_content'), "http://troper-mp.local/~localadmin/rally_scheduler_content.html?timestamp=" + timestamp);
dynamic_load_behavior($('gadget_content'), "http://troper-mp.local/~localadmin/rally_scheduler_behavior.js?timestamp=" + timestamp);

